﻿using MyMusicPlay._4._0.Manager;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MyMusicPlay._4._0
{
    public class TimerAction
    {
        private static int _maxIndex = 0;

        public Action action;

        private int _index = 0;

        public string FunctionName;
        public string FunctionPath;
        public int FunctionLine;

        public TimerAction(Action action,
            [CallerMemberName] string memberName = "",
            [CallerFilePath] string sourceFilePath = "",
            [CallerLineNumber] int sourceLineNumber = 0)
        {
            this.action = action;
            _index = NewIndex();

            FunctionName = memberName;
            FunctionPath = sourceFilePath;
            FunctionLine = sourceLineNumber;
        }

        private int NewIndex()
            => Interlocked.Increment(ref _maxIndex);

        public int ID
        {
            get
            {
                return _index;
            }
        }
    }
}
